/* Public defines and interface for SPI */

/* Copyright (C) 2009-2011 David Zanetti
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; version 2 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */


/* pin allocations */
/* the actual SPI port, excluding any chip select */
#define MOSI PORTB5
#define MISO PORTB6
#define SCK PORTB7
#define SPIPORT PORTB
#define SPIDDR DDRB

/* initalise the SPI interface. Does not reset CS. */
void spi_init(void);

/* perform SPI TX, followed by RX.
 * throw away return for TX, send '0' for RX and use return
 * Note: CS line must be asserted low before calling */
uint8_t spi_txrx(uint8_t c);


